﻿Namespace Controls
    ''' <summary>
    ''' 网页进度条
    ''' </summary>
    ''' <remarks></remarks>
    Public Module HProgressBar
        ''' <summary>
        ''' 进度条的初始化
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub Start()
            Start("正在加载...")
        End Sub

        ''' <summary>
        ''' 进度条的初始化
        ''' </summary>
        ''' <param name="msg">最开始显示的信息</param>
        ''' <remarks></remarks>
        Public Sub Start(ByVal msg As String)
            Dim s = "<html xmlns=""http://www.w3.org/1999/xhtml"">" & Chr(13) & "" & Chr(10) & "<head>" & Chr(13) & "" & Chr(10) & "<title></title>" & Chr(13) & "" & Chr(10) & "" & Chr(13) & "" & Chr(10) & ""
            s &= "<link href=""css/css.css"" rel=""stylesheet"" type=""text/css"" />" & Chr(13) & "" & Chr(10) & ""
            s &= "<style>body {text-align:center;margin-top: 50px;}#ProgressBarSide {height:25px;border:1px #2F2F2F;width:65%;background:#EEFAFF;}</style>" & Chr(13) & "" & Chr(10) & ""
            s &= "<script language=""javascript"">" & Chr(13) & "" & Chr(10) & ""
            s &= "function SetPorgressBar(msg, pos)" & Chr(13) & "" & Chr(10) & ""
            s &= "{" & Chr(13) & "" & Chr(10) & ""
            s &= "document.getElementById('ProgressBar').style.width = pos + ""%"";" & Chr(13) & "" & Chr(10) & ""
            s &= "WriteText('Msg1',msg + "" 已完成"" + pos + ""%"");" & Chr(13) & "" & Chr(10) & ""
            s &= "}" & Chr(13) & "" & Chr(10) & ""
            s &= "function SetCompleted(msg)" & Chr(13) & "" & Chr(10) & "{" & Chr(13) & "" & Chr(10) & "if(msg=="""")" & Chr(13) & "" & Chr(10) & "WriteText(""Msg1"",""完成。"");" & Chr(13) & "" & Chr(10) & ""
            s &= "else" & Chr(13) & "" & Chr(10) & "WriteText(""Msg1"",msg);" & Chr(13) & "" & Chr(10) & "}" & Chr(13) & "" & Chr(10) & ""
            s &= "function WriteText(id, str)" & Chr(13) & "" & Chr(10) & ""
            s &= "{" & Chr(13) & "" & Chr(10) & ""
            s &= "var strTag = '<span style=""font-family:Verdana, Arial, Helvetica;font-size=11.5px;color:#DD5800"">' + str + '</span>';" & Chr(13) & "" & Chr(10) & ""
            s &= "document.getElementById(id).innerHTML = strTag;" & Chr(13) & "" & Chr(10) & ""
            s &= "}" & Chr(13) & "" & Chr(10) & ""
            s &= "</script>" & Chr(13) & "" & Chr(10) & "</head>" & Chr(13) & "" & Chr(10) & "<body>" & Chr(13) & "" & Chr(10) & ""
            s &= "<div id=""Msg1""><span style=""font-family:Verdana, Arial, Helvetica;font-size=11.5px;color:#DD5800"">" + msg + "</span></div>" & Chr(13) & "" & Chr(10) & ""
            s &= "<div id=""ProgressBarSide"" align=""left"" style=""color:Silver;border-width:1px;border-style:Solid;"">" & Chr(13) & "" & Chr(10) & ""
            s &= "<div id=""ProgressBar"" style=""background-color:#008BCE; height:25px; width:0%;color:#fff;""></div>" & Chr(13) & "" & Chr(10) & ""
            s &= "</div>" & Chr(13) & "" & Chr(10) & "</body>" & Chr(13) & "" & Chr(10) & "</html>" & Chr(13) & "" & Chr(10) & ""
            System.Web.HttpContext.Current.Response.Write(s)
            System.Web.HttpContext.Current.Response.Flush()
        End Sub

        ''' <summary>
        ''' 滚动进度条
        ''' </summary>
        ''' <param name="Msg">在进度条上方显示的信息</param>
        ''' <param name="Pos">显示进度的百分比数字</param>
        ''' <remarks></remarks>
        Public Sub Roll(ByVal Msg As String, ByVal Pos As Integer)
            Dim jsBlock = "<script language=""javascript"">SetPorgressBar('" & Msg & "'," & Pos & ");</script>"
            System.Web.HttpContext.Current.Response.Write(jsBlock)
            System.Web.HttpContext.Current.Response.Flush()
        End Sub
    End Module
End Namespace